clear all
clc

cd('../../../../cvx_2.2.2')
cvx_setup

warning('off','MATLAB:nargchk:deprecated')
warning('off','MATLAB:illConditionedMatrix')

cd('../bernstein_simulations/J3/codes')

%% DGP

J = 3;    % # of goods
N = 20000;  % # of individuals

alpha = 1;
beta = 1;

mu_x = 0;
mu_z = 0;

sigma_x = 1;
sigma_z = 1;

mu_c = -1;
sigma_c = 4;

%% PREP FOR ESTIMATION

m_regr = [3 4 3*ones(1,J-2) 4 4 3*ones(1,J-2)];

[combos_all_unique] = combinations_10(m_regr,J);

% constraints

[Aineq,bineq] = constraint_mat_theta_2(combos_all_unique,J);

Aeq = [];
beq = [];

ntheta = size(Aineq,2);

ss=61;

rng(10101010*ss+ss^2)

tic

[data,data_trans] = generate_data_simult(N,J,mu_x,sigma_x,mu_z,sigma_z,alpha,beta,mu_c,sigma_c);

%% ESTIMATION ROUTINE

[theta_NPD,fval_NPD,flag_NPD] = estimation_NPD_cvx(data_trans,J,N,m_regr,Aineq,Aeq,bineq,beq,...
    combos_all_unique,ntheta);

toc

save('../results/simult/MC_61.mat')

script_ratio

clear data* bineq Aineq input_list output_list

cd('../results/simult')

save('MC_61.mat')



